package upbeat;

import upbeat.types.Cue;
import upbeat.types.Measure;

/**
 * The base class of compiler generated Musicians, providing all necessary
 * methods of music manipulation.
 * 
 * @author Fan Lin
 * 
 */
public abstract class Musician implements MusicianInterface {
	private Track mTrack;
	private int channel = 0;
	
	protected Musician(int chan) {
		mTrack = new Track();
		channel = chan;
		if(channel == 9 || channel > 15) { // special case for drum channel - skip it!
			throw new Error("Upbeat currently only supports 15 musicians, none of them on channel 10, to comply with MIDI restrictions");
		}
	}
	
	protected Track getMusicMaker()
	{
		return mTrack;
	}
	
	public int getChannel() {
		return channel;
	}

	public Measure GetNextMeasure() {
		return mTrack.getNextMeasure();
	}

	/**
	 * The main function of the Musician.
	 * @param cue
	 */
	public abstract void processCue(Cue cue) throws Exception;	
}
